<?php
  $str = $_GET['str'];
  
  if (strlen($str) == 0) exit;

  $con = mysql_connect("mysql1.000webhost.com", "a7424976_info", "thebest5");
	$res = mysql_select_db("a7424976_info");
	
	$queryres = mysql_query("select distinct name from inventory");
	
  while(($row = mysql_fetch_row($queryres))){
  if (stripos($row[0], $str) !== FALSE){
    $q1 = mysql_query("select * from inventory where name='$row[0]' and state = 0");
    $num1 = mysql_num_rows($q1);
    $q2 = mysql_query("select * from inventory where name='$row[0]' and state = 1");
    $num2 = mysql_num_rows($q2);
    echo "$row[0]-$num+";
  }
 }
  	mysql_close($con);
?>	